import subprocess
import time

def ping_check(host, showoutput):
    proc = subprocess.Popen(
        ['ping', '-n', '3', host],
        stdout=subprocess.PIPE)

    stdout, stderr = proc.communicate()

    if proc.returncode == 0:
        print('{} is UP'.format(host))
    else:
        print('{} is DOWN'.format(host))

    if showoutput == 1:
        print('ping output:')
        print(stdout.decode('ASCII'))


def GetCurTime():
    return time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))

def main():
    ipaddress = '114.114.114.114'

    print(GetNowTime())
    ping_check(ipaddress, 0)


if __name__ == '__main__':
    main()
